Update Assessment Form
Introduction
An Assessment form may be updated by the Assetic REST API PUT /api/v2/assessmentform/{id} where {id} is the name of the Assessment form.
Payload
The structure of the payload used for updating the Assessment form is described in the article Create Assessment Form.
The Assetic REST API GET /api/v2/assessmentform/{id} is used to get the current structure of the form. Since the PUT requires the entire form definition the best approach is to first use the GET API and modify that GET response to use as the input payload for the PUT update.
Each control, widget, layout etc within the form has a 'Name' property that uniquely identifies that object. This value should not be modified, otherwise it will be assumed the object is new.
Note that the payload used by the POST /api/v2/assessmentform API can also be modified and used in the PUT with the exception that the Name property for the FormLayout object, and the FormLayoutPattern object are system generated, so it is necessary to use the API GET /api/v2/assessmentform/{id} to get the system generated names for these two form objects.
Setting Combobox Parent-Child Relationship
Relationships can be established between items in 2 comboboxes in a 'Parent-Child' structure where choosing an item in the 'Parent' combobox will filter the list of items in the 'Child' comboxbox.
The application of relationships requires:
-
The 'Name' property of the 'Parent' combobox to be recorded against the 'Child' combobox using the 'FORMControlParentName' property of the 'Child' combobox.
-
For each item in the 'Child' combobox apply to the property 'ParentItemIds' a list of item Id's from the 'Parent' combobox using the 'Id' property of the item.
The example payload below has a 'Parent' comboxbox titled "System" and a 'Child' combobox titled 'Sub System'
{
"Name": "C03fce8def0b311ea9da2f4d108e253be",
"Label": "System",
"HelpString": "",
"Visible": true,
"Required": true,
"Readonly": false,
"SortOrder": 2,
"Type": 10,
"TypeName": "UdfCombobox",
"DataType": "string",
"ComboboxItems": [
{
"Id": "86e05373-243d-4597-86d1-211d1ccdae4d",
"Label": "All",
"Value": "3",
"SortOrder": 2,
"CbStatusEnum": "Active",
"FORMControlCBItemParentId": "",
"ParentItemIds": null,
"_links": [],
"_embedded": null
},
{
"Id": "ee33b09d-50b1-4c63-b31b-86317aff8202",
"Label": "Type A",
"Value": "1",
"SortOrder": 0,
"CbStatusEnum": "Active",
"FORMControlCBItemParentId": "",
"ParentItemIds": null,
"_links": [],
"_embedded": null
},
{
"Id": "4c082a4f-704c-49da-98ef-52a6775ff573",
"Label": "Type B",
"Value": "2",
"SortOrder": 1,
"CbStatusEnum": "Active",
"FORMControlCBItemParentId": "",
"ParentItemIds": null,
"_links": [],
"_embedded": null
}
],
"FORMControlParentName": null,
"Calculation": null,
"CalculationFields": [],
"CalculationResult": "",
"NumericMin": null,
"NumericMax": null,
"NumericMask": null,
"NumericStep": 0,
"TextLength": null,
"LabelWeight": null,
"_links": [],
"_embedded": null
},
{
"Name": "C03fce8dff0b311eab14ef4d108e253be",
"Label": "Sub System",
"HelpString": "Child of System",
"Visible": true,
"Required": true,
"Readonly": false,
"SortOrder": 3,
"Type": 10,
"TypeName": "UdfCombobox",
"DataType": "string",
"ComboboxItems": [
{
"Id": "1112f169-e9c5-4bc7-a9b3-4785b3e33841",
"Label": "Sub A1",
"Value": "1",
"SortOrder": 0,
"CbStatusEnum": "Active",
"FORMControlCBItemParentId": "",
"ParentItemIds": [
"ee33b09d-50b1-4c63-b31b-86317aff8202",
"86e05373-243d-4597-86d1-211d1ccdae4d"
],
"_links": [],
"_embedded": null
},
{
"Id": "7d722c05-69c1-46dc-8421-2282aaa83e10",
"Label": "Sub A2",
"Value": "2",
"SortOrder": 1,
"CbStatusEnum": "Active",
"FORMControlCBItemParentId": "",
"ParentItemIds": [
"ee33b09d-50b1-4c63-b31b-86317aff8202",
"86e05373-243d-4597-86d1-211d1ccdae4d"
],
"_links": [],
"_embedded": null
},
{
"Id": "78952a48-b136-4796-b026-41cd56a56777",
"Label": "Sub B1",
"Value": "3",
"SortOrder": 2,
"CbStatusEnum": "Active",
"FORMControlCBItemParentId": "",
"ParentItemIds": [
"4c082a4f-704c-49da-98ef-52a6775ff573",
"86e05373-243d-4597-86d1-211d1ccdae4d"
],
"_links": [],
"_embedded": null
},
{
"Id": "08d09fab-c220-49ef-af36-2f8da947e110",
"Label": "Sub B2",
"Value": "4",
"SortOrder": 3,
"CbStatusEnum": "Active",
"FORMControlCBItemParentId": "",
"ParentItemIds": [
"86e05373-243d-4597-86d1-211d1ccdae4d",
"4c082a4f-704c-49da-98ef-52a6775ff573"
],
"_links": [],
"_embedded": null
}
],
"FORMControlParentName": "C03fce8def0b311ea9da2f4d108e253be",
"Calculation": null,
"CalculationFields": [],
"CalculationResult": "",
"NumericMin": null,
"NumericMax": null,
"NumericMask": null,
"NumericStep": 0,
"TextLength": null,
"LabelWeight": null,
"_links": [],
"_embedded": null
},
For the above payload, the table below lists the items that are selectable for 'Sub System based on the item in 'System':
System | Sub System |
Type A | Sub A1, Sub A2 |
Type B | Sub B1, Sub B2 |
All | Sub A1, Sub A2, Sub B1, Sub B2 |
Adding controls
A new control may be added to the form by adding the control definition to a FormControl array within the form payload. The structure of the control definition is the same as for Form Creation.
Hiding unwanted controls
If a control is to be removed from the form then the best approach is to set the "Visible" property to "false", and the "Required" property to "false" because the API does not support the removal of a control. The example below will hide the "DatePicker" with the label "Tagged Service Date"
{
"TypeName": "DatePicker",
"Name": "KC5e5a6a4a72d611e89e383c15c2bb918f",
"SortOrder": 1,
"DataType": "DateTime",
"HelpString": "Last date serviced",
"Label": "Tagged Service Date",
"Required": false,
"Visible": false
}